//package com.maxlen.order.controller;
//
//import com.maxlen.common.utils.R;
//import com.maxlen.order.entity.OrderEntity;
//import org.springframework.amqp.core.AmqpAdmin;
//import org.springframework.amqp.core.Binding;
//import org.springframework.amqp.core.DirectExchange;
//import org.springframework.amqp.core.Queue;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//@RestController
//@RequestMapping("/hello")
//public class HelloController {
//
//    @Autowired
//    private AmqpAdmin amqpAdmin;
//
//    @Autowired
//    private RabbitTemplate rabbitTemplate;
//
//    @RequestMapping("sendMessage")
//    public R sendMessage(){
//
//        OrderEntity orderEntity = new OrderEntity();
//        orderEntity.setOrderSn("dsadsa");
//        orderEntity.setId(1L);
//        for (int i = 0; i < 10; i++) {
//            rabbitTemplate.convertAndSend("hello-java-exchange", "hello.java", orderEntity);
//        }
//        return R.ok();
//    }
//
//    @RequestMapping("/create")
//    public R create(){
//        DirectExchange directExchange = new DirectExchange("hello-java-exchange", true, false);
//        amqpAdmin.declareExchange(directExchange);
//        return R.ok();
//    }
//
//    @RequestMapping("/createQueue")
//    public R createQueue(){
//        Queue queue = new Queue("hello-java-queue", true, false, false);
//        amqpAdmin.declareQueue(queue);
//        return R.ok();
//    }
//
//    @RequestMapping("binding")
//    public R binding(){
//        Binding binding = new Binding("hello-java-queue", Binding.DestinationType.QUEUE, "hello-java-exchange", "hello.java", null);
//        amqpAdmin.declareBinding(binding);
//        return R.ok();
//    }
//
//}
